//index.js
//获取应用实例
var app = getApp(),
    gd = app.globalData,
    $ = gd.$;
Page({
  data: {
    articleData: {}
  },
  onLoad: function (option) {
    // 当前页面初始化jwxa
    $.jwxa(this);

    // 设置id
    $.data('id', option.id);

    // 加载详细数据
    this.loadDetailData();
  },
  loadDetailData: function () {
    // 请求网络数据, 设置html数据
    /*
    $.get( gd.httpUrl + 'news/'+(this.data.id)+'.jspx', function (res) {
      $.html('articleData', res.data.data);
    });
    */
    $.get( 'http://jwxa.oss-cn-shenzhen.aliyuncs.com/'+(this.data.id)+'.json', function (res) {
      $.html('articleData', res.data.data);
    });
  },
  // 加载本地数据
  loadDetailLocal: function () {
    // 本地文章数据
    var articleData = {
      "childs": [
        {
          "attr": {
            "id": "tt-video-box",
            "data-tt-poster": "http://p1.pstatp.com/large/15b00007f6031ca91765",
            "class": "tt-video-box"
          },
          "childs": [
            {
              "attr": {
                "controls": "",
                "src": "http://www.w3school.com.cn/i/movie.ogg",
                "width": "640",
                "playsinline": "playsinline",
                "id": "tt-video",
                "poster": "http://p1.pstatp.com/large/15b00007f6031ca91765",
                "preload": "true",
                "class": "tt-video",
                "height": "320",
                "webkit-playsinline": "webkit-playsinline"
              },
              "childs": [],
              "nodeName": "element",
              "nodeType": "video",
              "tagName": "video"
            }
          ],
          "nodeName": "element",
          "nodeType": "view",
          "tagName": "div"
        }
      ],
      "imageUrls": [],
      "nodeName": "root",
      "nodeType": "root"
    };
    // 设置html数据
    $.html('articleData', articleData);
  }
})
